﻿using System;
using System.Windows.Forms;

namespace INIGui.Dialogs
{
    public partial class DialogAddSection : Form
    {

        /// <summary>
        /// The name of the section to retrieve.
        /// </summary>
        public string SectionName { get; private set; }

        public DialogAddSection()
        {
            InitializeComponent();
        }

        private void BtnOkayClick(object sender, EventArgs e)
        {
            SectionName = tbSection.Text;    
        }

        private void TbSectionTextChanged(object sender, EventArgs e)
        {
            if (tbSection.Text.Contains("=") || tbSection.Text.Equals(string.Empty))
            {
                epValidaton.SetError(tbSection, "The section name cannot contain an equals sign or be blank!");
                btnOkay.Enabled = false;
            }
            else
            {
                btnOkay.Enabled = true;
            }
        }

        private void BtnCancelClick(object sender, EventArgs e)
        {
            Close();
        }
    }
}
